class CartItem
  attr_accessor :item_id, :product_id, :color_id, :quantity
  
  def initialize(product_id, color_id, quantity)
    @item_id = "I#{product_id}#{color_id}"
    @product_id = product_id
    @color_id = color_id
    @quantity = quantity.to_i
  end

  def update_quantity(quantity, client_id)
    @quantity = quantity.to_i
    SavedCart.update_item(client_id, self, true)
  end

  def subtotal(kvn_branch)
      product = Product.find(@product_id)
      product.get_price(kvn_branch) * @quantity
  end
end